package itheima.controller;

import itheima.domain.Book;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/books")
public class BookController {
    @PostMapping
    public String save(@RequestBody Book book){
        System.out.println("book save ==>" +book);
        return "{'module':'book save success'}";
    }

    @GetMapping
    public List<Book> getAll(){
        List<Book> list=new ArrayList<>();

        Book book1=new Book();
        book1.setName("shu");
        book1.setAge(43);
        book1.setAddress("kan");
        list.add(book1);

        Book book2=new Book();
        book2.setName("manhua");
        book2.setAge(88);
        book2.setAddress("kan");
        list.add(book2);
        return list;
    }
}
